{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3054
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var
	i,n:longint;
 
procedure tower(k,a,b,c:longint);
begin
if k>1 then tower(k-1,a,c,b);
writeln(k,' ',a,' ',b);
if k>1 then tower(k-1,c,b,a);
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
for i:=n downto 1 do begin
	if not odd(i) then begin
		tower(i,1,3,2);
		if i>1 then tower(i-1,3,1,2);
	end else begin
		tower(i,1,2,3);
		if i>1 then tower(i-1,2,1,3);
	end;
end;
end.